/**
 * 生成验证码测试
 */
public class VerificationCode {
    private static String DATA = "zxcvbnmasdfghjklqwertyuiopZXCVBNMASDFGHJKLQWERTYUIOP1234567890";
    public static void main(String[] args){
        String code = getCode(6);
        System.out.println("生成的验证码是: " + code);
    }
    /**
     * 生成指定长度的验证码
     * @param length 验证码长度
     * @return 生成的验证码字符串
     */
    public static String getCode(int length) {
        StringBuilder code = new StringBuilder();
        for (int i = 0; i < length; i++) {
            int index = (int) (Math.random() * DATA.length());
            code.append(DATA.charAt(index));
        }
        return code.toString();
    }
}
